import ObstacleConfig, { SpecifyColor } from "./ObstacleConfig";

const { ccclass, property } = cc._decorator;

@ccclass
export default class DrillFill extends cc.Component {
    @property(cc.Node)
    drillSpineNode = null;

    @property(cc.Label)
    leftCountLab = null;

    initDrill(e, t, a) {
        switch (e) {
            case 0:
                this.drillSpineNode.x = 40;
                this.drillSpineNode.y = -80;
                this.drillSpineNode.angle = 0;
                this.leftCountLab.node.angle = 0;
                break;

            case 1:
                this.drillSpineNode.x = 80;
                this.drillSpineNode.y = -40;
                this.drillSpineNode.angle = -90;
                this.leftCountLab.node.angle = 90;
                break;

            case 2:
                this.drillSpineNode.x = 40;
                this.drillSpineNode.y = -80;
                this.drillSpineNode.angle = 180;
                this.leftCountLab.node.angle = -180;
                break;

            case 3:
                this.drillSpineNode.x = 0;
                this.drillSpineNode.y = -40;
                this.drillSpineNode.angle = 90;
                this.leftCountLab.node.angle = -90;
        }
        
        let o = "";
        
        switch (a) {
            case SpecifyColor.blueShield:
                o = "Drill_Lan";
                break;

            case SpecifyColor.greenLeaf:
                o = "Drill_Lv";
                break;

            case SpecifyColor.redBook:
                o = "Drill_Hong";
                break;

            case SpecifyColor.yellowCrown:
                o = "Drill_Huang";
                break;

            case SpecifyColor.purpleGem:
                o = "Drill_Zi";
        }
        
        this.updateLeftCount(t);
        this.drillSpineNode.getComponent(sp.Skeleton).setSkin(o);
        this.drillSpineNode.getComponent(sp.Skeleton).setAnimation(0, "idle_1", false);
        console.error("initDrill---", e, t, a, this.node);
    }

    updateLeftCount(e) {
        this.leftCountLab.string = "" + e;
    }

    onclearOne(e) {
        this.drillSpineNode.getComponent(sp.Skeleton).setAnimation(0, "idle_2", false);
        this.updateLeftCount(e);
    }

    clearAllDrill() {
        this.node.active = false;
    }
}
